<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>

<body>
  <script>
    // console.log('广告显示');
    // var timer = setTimeout(fn, 3000);
    // function fn() {
    //   console.log('广告关闭了');
    // }

    var interval = setInterval(function () {
      console.log(new Date());
    }, 1000)
    setTimeout(function(){
      clearInterval(interval)
    }, 3000)
  </script>
</body>

</html>